import java.util.Iterator;
import java.util.Set;

import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.widgets.Canvas;


public class DrawEnvironment implements PaintListener{
	private Simulation sim;
	
	public DrawEnvironment(Simulation sim){
		this.sim = sim;
	}
	
	// the drawing implemented method
	public void paintControl(PaintEvent e) {	
		Canvas c =(Canvas)e.widget;	// get the canvas
		int maxX = c.getSize().x;	// max size
		int maxY = c.getSize().y;
		int mx=maxX/2,my=maxY/2;	// mid point as (0,0)

		e.gc.drawOval(mx-2, my-2, 4, 4);// point at the middle.
		
		//paints all robots and boxes to canvas
		Set<String> strings = sim.getAllRobotNames();
		Iterator<String> it = strings.iterator();
		while(it.hasNext()){
				sim.getRobot(it.next()).paint(e);
		}
			
		sim.boxes.paint(e);
	
	}
}